package com.woniuxy.common;

import lombok.Data;

/**
 * Auther: Hello Mr. Guo  <br/>
 * Date: 10:09:  <br/>
 * Description: 响应状态码
 */

@Data
public class CommonResult<T> {

    /**
     * 响应状态码
     */
    private int code;

    /**
     * 响应消息
     */
    private String message;

    /**
     * 响应数据
     */
    private T data;

    public CommonResult() {
    }

    public CommonResult(T data) {
        this.data = data;
    }

    public CommonResult(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public CommonResult(int code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static <T> CommonResult success(T data){
        return new CommonResult(ResultEnum.SUCCESS.getCode(),ResultEnum.SUCCESS.getMessage(),data);
    }

    public static <T> CommonResult fail(){

        return new CommonResult(ResultEnum.ERROR.getCode(),ResultEnum.ERROR.getMessage());
    }




}
